package com.smartcruise.main.mainFragment.messageNotice.messageNoticeDetail;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.smartcruise.R;
import com.smartcruise.base.BaseTitleFragment;
import com.smartcruise.base.TitleBuilder;
import com.smartcruise.data.MessageNotice;
import com.smartcruise.util.IntentUtils;

import java.util.Random;

import butterknife.BindView;
import butterknife.Unbinder;

/**
 * Created by FengChaoQun
 * on 2018/1/21 0021
 * 审核详情
 */

public class AuditDetailFragment extends BaseTitleFragment {

    @BindView(R.id.auditResultText)
    TextView auditResultText;
    @BindView(R.id.extraText)
    TextView extraText;
    @BindView(R.id.auditResultLay)
    LinearLayout auditResultLay;
    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.deviate)
    TextView deviate;
    @BindView(R.id.submitDate)
    TextView submitDate;
    @BindView(R.id.auditDate)
    TextView auditDate;
    @BindView(R.id.auditPeople)
    TextView auditPeople;
    @BindView(R.id.sos)
    TextView sos;
    @BindView(R.id.report)
    TextView report;
    @BindView(R.id.navigation)
    TextView navigation;
    Unbinder unbinder;
    private MessageNotice messageNotice;

    public static AuditDetailFragment newInstance(MessageNotice messageNotice) {
        Bundle bundle = new Bundle();
        bundle.putSerializable(IntentUtils.DATA, messageNotice);
        AuditDetailFragment signInDetailFragment = new AuditDetailFragment();
        signInDetailFragment.setArguments(bundle);
        return signInDetailFragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            messageNotice = (MessageNotice) getArguments().getSerializable(IntentUtils.DATA);
        }
        if (messageNotice == null) {
            showToast(getString(R.string.nothingToShow));
            getActivity().finish();
        }
    }

    @Override
    protected void init() {
        setCloseActivity();

        Random random = new Random();
        if (random.nextBoolean()) {
            auditResultLay.setBackgroundColor(getResources().getColor(R.color.auditSuccess));
            auditResultText.setText(R.string.completeTask);
            extraText.setText("评价：良 同志仍需努力");
        } else {
            auditResultLay.setBackgroundColor(getResources().getColor(R.color.auditRefused));
            auditResultText.setText(R.string.outOfCourt);
            extraText.setText("驳回原因");
        }
    }

    @Override
    protected int getContentLayout() {
        return R.layout.fragment_container_audit_detail;
    }

    @Override
    protected TitleBuilder getTitleBuilder() {
        return TitleBuilder.create(true, "任务类型");
    }

}
